package com.gm.commonlib.network.basenetwork.gson;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;

import java.lang.annotation.Annotation;
import java.util.Collection;

/**
 * Created by aiyongkun on 2017/4/22.
 */
public class IgnoreStrategy implements ExclusionStrategy {
    @Override
    public boolean shouldSkipField(FieldAttributes f) {
        Collection<Annotation> annotations = f.getAnnotations();
        for (Annotation annotation : annotations) {
            if (annotation.annotationType() == Ignore.class) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean shouldSkipClass(Class<?> clazz) {
        return false;
    }
}
